#include <sys/types.h>
#include <hw/io.h>
#include <hw/led.h>

HW::Led::Led(enum eBank bank, uint8_t bit)
{
    _bit = bit;
    
    switch ( bank ) 
    {
        case BANKA:
            break;
            
        case BANKB:
            _DDR = &HW::RCore->DDRB;
            _PORT = &HW::RCore->PORTB;
            break;
            
        case BANKC:
            _DDR = &HW::RCore->DDRB;
            _PORT = &HW::RCore->PORTB;
            break;

        case BANKD:
            _DDR = &HW::RCore->DDRB;
            _PORT = &HW::RCore->PORTB;
            break;
    }
    
    *_PORT |= bit;
}

void HW::Led::shine(void )
{
    *this->_DDR |= this->_bit;
}

void HW::Led::clear(void )
{
    *this->_DDR &= ~(this->_bit);
}

bool HW::Led::status(void )
{
    return (*this->_DDR & this->_bit);
}